<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
    <meta name="description" content="">
    <meta name="author" content="">
<#--<link rel="icon" href="../../favicon.ico">-->

    <title>资源管理系统</title>

    <!-- Bootstrap core CSS -->
    <link href="/static/dist/css/bootstrap.min.css" rel="stylesheet">

    <!-- Custom styles for this template -->
    <link href="/static/dist/css/navbar-fixed-top.css" rel="stylesheet">

    <style>
        #pleaseWaitDialog {
            top: 30%;
        }
    </style>
    <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
    <!--[if lt IE 9]>
    <!--<script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>-->
    <!--<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>-->
    <![endif]-->
</head>

<body ng-app="customerApp" ng-controller="customerCtrl">

<!-- Fixed navbar -->
<nav class="navbar navbar-default navbar-fixed-top">
    <div class="container">
        <div class="navbar-header">
            <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar"
                    aria-expanded="false" aria-controls="navbar">
                <span class="sr-only">Toggle navigation</span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
            </button>
            <a class="navbar-brand" href="#">C-R-M</a>
        </div>
        <div id="navbar" class="navbar-collapse collapse">
            <ul class="nav navbar-nav">
                <li><a href="/admin/account/index">资源管理</a></li>
                <li><a href="javascript:alert('功能持续开发中...')">字典管理</a></li>
                <li class="active"><a href="/admin/customer/index">客户管理</a></li>
                <li><a href="/admin/account/data">数据管理</a></li>
            </ul>
            <div id="navbar" class="navbar-collapse collapse">
                <form class="navbar-form navbar-right">
                    <div class="form-group">
                        <input type="text" placeholder="Email" class="form-control">
                    </div>
                    <div class="form-group">
                        <input type="password" placeholder="Password" class="form-control">
                    </div>
                    <button type="submit" class="btn btn-success">Sign in</button>
                </form>
            </div>
        </div><!--/.nav-collapse -->
    </div>
</nav>

<div class="container">
    <div class="panel panel-default">
        <!-- Default panel contents -->
        <div class="panel-heading">客户管理</div>
        <div class="panel-body">
            <div id="navbar" class="navbar-collapse collapse">
                <form id="customerForm" name="customerForm" class="navbar-form navbar-left">
                    <input type="hidden" name="id" value="{{customerModel.id}}">
                    <div class="form-group">
                        <label>客户名称:</label>
                        <input type="text" name="customerName" placeholder="客户名称" class="form-control"
                               ng-model="customerModel.customerName">
                    </div>
                    <div class="form-group">
                        <label>阀值:</label>
                        <input type="number" min="0" name="boundary" placeholder="阀值" class="form-control"
                               ng-model="customerModel.boundary">
                    </div>
                    <div class="form-group">
                        <label>加价:</label>
                        <input type="number" min="0" name="fixedValue" placeholder="加价" class="form-control"
                               ng-model="customerModel.fixedValue">
                    </div>
                    <div class="form-group">
                        <label>系数:</label>
                        <input type="number" min="0" step="0.1" name="coefficient" placeholder="系数" class="form-control"
                               ng-model="customerModel.coefficient">
                    </div>
                    <div class="checkbox">
                        <label>
                            <input type="checkbox" ng-true-value="1" ng-false-value="0"
                                   ng-model="customerModel.useDiscount" name="useDiscount">使用优惠
                        </label>
                    </div>
                    <button type="button" ng-show="add_customer" class="btn btn-success"  ng-click="addCustomer()">提交</button>
                    <button type="button" ng-show="update_customer" class="btn btn-primary"  ng-click="updateCustomer()">修改</button>
                </form>
            </div>
        </div>
        <table class="table table-bordered table-hover">
            <thead>
            <tr>
                <th>序号</th>
                <th>客户名称</th>
                <th>阀值</th>
                <th>系数</th>
                <th>加价</th>
                <th>使用优惠</th>
                <th style="text-align: center">操作</th>
            </tr>
            </thead>
            <tbody>
            <tr ng-repeat="customer in customers" >
                <th>{{customer.id}}</th>
                <td>{{customer.customerName}}</td>
                <td>{{customer.boundary}}</td>
                <td>{{customer.coefficient}}</td>
                <td>{{customer.fixedValue}}</td>
                <td>{{fomatDiscount(customer.useDiscount)}}</td>
                <td>
                    <button type="button" class="btn btn-info"  ng-click="loadCustomerData(customer)">修改
                    </button>
                    <button type="button" class="btn btn-danger" ng-click="deleteCustomer(customer.id)">删除
                    </button>
                </td>
            </tr>
            </tbody>
            <tfoot>
            <tr>
                <td colspan="14" align="center">
                    <ul class="pagination">
                        <li ng-class="prevPageDisabled()"><a href="javascript:void(0);" ng-click="firstPage()"> &lt;&lt; </a></li>
                        <li ng-class="prevPageDisabled()"><a href="javascript:void(0);" ng-click="prevPage()">&lt;</a></li>
                        <li ng-repeat="n in pageItems" ng-class="{active: n == currentPage}">
                            <a href="javascript:void(0);" ng-click="setPage(n)">{{n}}</a>
                        </li>
                        <li ng-class="nextPageDisabled()"><a href="javascript:void(0);" ng-click="nextPage()">&gt;</a></li>
                        <li ng-class="nextPageDisabled()"><a href="javascript:void(0);" ng-click="lastPage()">&gt;&gt;</a></li>
                    </ul>
                </td>
            </tr>
            </tfoot>
        </table>
    </div>
    <div id="delete-alert" class="alert alert-danger alert-dismissible fade in" role="alert">
        <button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button>
        <h4>Oh snap! You got an error!</h4>
        <p>Change this and that and try again. Duis mollis, est non commodo luctus, nisi erat porttitor ligula, eget lacinia odio sem nec elit. Cras mattis consectetur purus sit amet fermentum.</p>
        <p>
            <button type="button" class="btn btn-danger">Take this action</button>
            <button type="button" class="btn btn-default">Or do this</button>
        </p>
    </div>

    <!-- Bootstrap core JavaScript
    ================================================== -->
    <!-- Placed at the end of the document so the pages load faster -->
    <script src="/static/dist/js/jquery.1.11.3.min.js"></script>
    <script src="/static/dist/js/bootstrap.min.js"></script>
    <script src="/static/dist/js/plugins/angular.min.js"></script>
    <script src="/static/dist/js/controller/customer-controller.js"></script>

</body>
</html>
